﻿
/// <reference path="../components/Component.js" />

/*****************************************************************************
Ajax library class definition. Kevin Robinson 2006.
Class: ajax.lang.SaveCheckStates
/*****************************************************************************/


ajax.lang.addNamespace("ajax.lang");

//-----------------------------------------------------------------------------
ajax.lang.SaveCheckStates = function(doc) // Constructor
{
    ajax.lang.SaveCheckStates.superConstructor.call(this, doc);
    
    this.checks = new Array();
}

//-----------------------------------------------------------------------------
ajax.lang.extend("ajax.lang.SaveCheckStates", "ajax.components.Component"); // Inherit


//-----------------------------------------------------------------------------
ajax.lang.SaveCheckStates.prototype.save = function()
{
    this.checks = new Array();
    
    var inputs = this.doc.getElementsByTagName("INPUT");
    for (var i = 0; i < inputs.length; i++)
    {
        var tagName = inputs[i].type.toUpperCase();
        if (tagName == "CHECKBOX" || tagName == "RADIO")
            this.checks[this.checks.length] = {ele: inputs[i], checked: inputs[i].checked};
    }
}

//-----------------------------------------------------------------------------
ajax.lang.SaveCheckStates.prototype.restore = function()
{
    // Set the checks back, use the shortcuts stored in our array.
    for (var i = 0; i < this.checks.length; i++)            
        this.checks[i].ele.checked = this.checks[i].checked; 
}

//-----------------------------------------------------------------------------
ajax.lang.SaveCheckStates.prototype.toString = function()
{
    return "ajax.lang.SaveCheckStates";
}

//-----------------------------------------------------------------------------
ajax.lang.SaveCheckStates.cast = function(obj)
{///<returns type="ajax.lang.SaveCheckStates"/>
    return obj;
}
